#pragma once
#include <iostream>
using namespace std;

template <typename ArrayType>
class Array
{
public:
	Array()
	{
		this->m_Capacity = 0;
		this->m_Size = 0;
		cout<<"Array()"<<endl;
	}
	Array(int capacity)
	{
		this->m_Capacity = capacity;
		this->m_Size = 0;
		this->m_Array = new ArrayType[this->m_Capacity];
		// cout<<this->m_Capacity<<"\t"<<this->m_Size<<"\t"<<*this->m_Array<<endl;
	}
	Array(const Array & array)
	{
		this->m_Capacity = array.m_Capacity;
		this->m_Size = array.m_Size;
		// this->m_Array = array.m_Array;
		this->m_Array = new ArrayType[array.m_Capacity];
		for (int i = 0; i < array.m_Size; ++i)
		{
			this->m_Array[i] = array.m_Array[i];
		}
		// cout<<this->m_Capacity<<"\t"<<this->m_Size<<"\t"<<*this->m_Array<<endl;
	}
	Array & operator=(const Array & array)
	{
		if(this->m_Array != NULL)
		{
			delete [] this->m_Array;
			this->m_Array = NULL;
			this->m_Capacity = 0;
			this->m_Size = 0;
		}
		this->m_Capacity = array.m_Capacity;
		this->m_Size = array.m_Size;
		// this->m_Array = array.m_Array;
		this->m_Array = new ArrayType[array.m_Capacity];
		for (int i = 0; i < array.m_Size; ++i)
		{
			this->m_Array[i] = array.m_Array[i];
		}
		// cout<<this->m_Capacity<<"\t"<<this->m_Size<<"\t"<<*this->m_Array<<endl;
		return * this;
	}
	void pushBack(const ArrayType & value)
	{
		if(this->m_Capacity == this->m_Size)
		{
			cout<<"capacity not enough"<<endl;
			return;
		}
		this->m_Array[this->m_Size] = value;
		this->m_Size++;
	}
	void popBack(const ArrayType & value)
	{
		if(this->m_Size == 0)
		{
			cout<<"capacity is null"<<endl;
			return;
		}
		this->m_Size--;
	}
	Array & operator[](int index)
	{
		return this->m_Array[index];
	}
	int getCapacity()
	{
		return this->m_Capacity;
	}
	int getSize()
	{
		return this->m_Size;
	}
	~Array()
	{
		if(this->m_Array != NULL)
		{
			delete [] this->m_Array;
			this->m_Array = NULL;
		}
	}
	ArrayType * m_Array;
	int m_Capacity;
	int m_Size;
};